<template>
  <div>
    <el-form
      :model="changeruleForm"
      :rules="changerules"
      ref="ref"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="文章标题" prop="name">
        <el-input v-model="changeruleForm.name"></el-input>
      </el-form-item>
      <el-form-item label="文章内容" prop="content">
        <quill-editor v-model="changeruleForm.content"></quill-editor>
      </el-form-item>
      <el-form-item label="视频地址" prop="address">
        <el-input v-model="changeruleForm.address"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="canclechange">取 消</el-button>
      <el-button type="primary" @click="surechange">确 定</el-button>
    </span>
  </div>
</template>

<script>
import { changearticle } from '@/assets/api/Interview/interview.js';
import { quillEditor } from 'vue-quill-editor'; // 调用富文本编辑器
import 'quill/dist/quill.snow.css'; // 富文本编辑器外部引用样式  三种样式三选一引入即可
export default {
  components: { quillEditor },
  props: {
    changeId: {
      required: true,
      type: Number,
    },
    changeruleForm: {
      required: true,
      type: [Array, String, Object],
    },
    changerules: {
      required: true,
      type: [Array, String, Object],
    },
  },
  created() {},
  methods: {
    surechange() {
      this.$refs.ref.validate(async (valid) => {
        if (valid) {
          await changearticle(this.changeId, {
            id: this.changeId,
            title: this.changeruleForm.name,
            articleBody: this.changeruleForm.content,
            videoURL: this.changeruleForm.address,
          });
          this.$emit('surechange');
          this.$refs.ref.resetFields();
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    canclechange() {
      this.$refs.ref.resetFields();
      this.$emit('canclechange');
    },
  },
};
</script>

<style>
</style>
